<?php

class Model_Log {

    protected $log_id;
    protected $date;
    protected $section;
    protected $action;
    protected $data;
    protected $ip;
    protected $who_id;

    public function __construct(array $options = null) {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value) {
        $method = 'set' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        }
        $this->$method($value);
    }

    public function __get($name) {
        $method = 'get' . ucfirst($name);
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid content property');
        } return $this->$method();
    }

    public function setOptions(array $options) {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
    }

    public function setLog_id($value) {
        $this->log_id = $value;
    }

    public function getLog_id() {
        return $this->log_id;
    }

    public function setDate($value) {
        $this->date = $value;
    }

    public function getDate() {
        return $this->date;
    }

    public function setSection($value) {
        $this->section = $value;
    }

    public function getSection() {
        return $this->section;
    }

    public function setAction($value) {
        $this->action = $value;
    }

    public function getAction() {
        return $this->action;
    }

    public function setData($value) {
        $this->data = $value;
    }

    public function getData() {
        return $this->data;
    }

    public function setIp($value) {
        $this->ip = $value;
    }

    public function getIp() {
        return $this->ip;
    }

    public function setWho_id($value) {
        $this->who_id = $value;
    }

    public function getWho_id() {
        return $this->who_id;
    }

    public function toArray() {
        return get_object_vars($this);
    }

}

